package com.nulldev.util.java.swing.fastEPane;

import javax.swing.text.Element;
import javax.swing.text.FlowView;
import javax.swing.text.View;

public class HTMLParagraphView extends javax.swing.text.html.ParagraphView {

    public static int MAX_VIEW_SIZE = 60;
 
    public HTMLParagraphView(final Element elem) {
        super(elem);
        strategy = new HTMLParagraphView.HTMLFlowStrategy();
    }
 
    public static class HTMLFlowStrategy extends FlowStrategy {
        protected View createView(FlowView fv, int startOffset, int spanLeft, int rowIndex) {
            View res = super.createView(fv, startOffset, spanLeft, rowIndex);
            if (res.getEndOffset()-res.getStartOffset() > MAX_VIEW_SIZE) {
                res = res.createFragment(startOffset, startOffset + MAX_VIEW_SIZE);
            }
            return res;
        }

    }
    
    public int getResizeWeight(final int axis) {
        return 0;
    }
 
}